package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Strategy;
import cn.wolfcode.trip.base.domain.StrategyCatalog;
import cn.wolfcode.trip.base.domain.Travel;
import cn.wolfcode.trip.base.query.StrategyCatalogQueryObject;
import cn.wolfcode.trip.base.query.StrategyQueryObject;
import cn.wolfcode.trip.base.service.IStrategyService;
import cn.wolfcode.trip.base.service.ITravelService;
import cn.wolfcode.trip.base.util.JsonResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("strategies")
public class StrategyController {
    @Autowired
    private IStrategyService strategyService;
    @Autowired
    private ITravelService travelService;

    @GetMapping
    public PageInfo<?> listAll(StrategyQueryObject qo){
        return strategyService.query(qo);
    }

    @GetMapping("/{id}")
    public Strategy getStrategyById(@PathVariable Long id){
        Strategy strategy = strategyService.getStrategyById(id);

        System.out.println("11111");
        return strategy;
    }

    @GetMapping("/travels")
    public PageInfo<?> getTravelByStrategyId(StrategyCatalogQueryObject qo){
        return travelService.selectTravelByStrategyId(qo);
    }
    @GetMapping("/strategyTitles")
    public Strategy getStrategyByTitle(String title){
        Strategy strategy = strategyService.getStrategyByTitle(title);
        return strategy;
    }

}
